﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            radioButton1.Checked = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int Temp = 0;
            if (radioButton1.Checked == true)
            {
                try
                {
                    Temp = int.Parse(textBox1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Please enter a numerical value.");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("Please enter a vaild tempreture.");
                }
                Temp = Temp * 9;
                Temp = Temp / 5;
                Temp = Temp + 32;
                label2.Text = Temp.ToString() + "°F";
                textBox1.Text = "";
            }
            if (radioButton2.Checked == true)
            {
                try
                {
                    Temp = int.Parse(textBox1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Please enter a numerical value.");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("Please enter a vaild tempreture.");
                }
                Temp = Temp - 32;
                Temp = Temp / 9;
                Temp = Temp * 5;
                label2.Text = Temp.ToString();
                label2.Text = Temp.ToString() + "°C";
                textBox1.Text = "";
            }
        }
    }
}
